<?php
//including header.php 
include '../../include/header.php';
//including page.php (It is a class which contain functions)
include '../../libraries/page.php';
//created object for page.php
$page = new page();

session_start();
if ($page->get_session()) {
    header("location:index.php");
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {

    $register = $page->register_user($_POST['name'], $_POST['email'], $_POST['password']);

    if ($register) {
// Registration Success
        header("location:login");
    } else {
        //Registration Failed
        $msg = $message[6];
    }
}
?>

<!----------------------------------Display the result message of Addition--------------------->
<div align="center"><? echo $msg; ?></div>

<!-------------------------Registration form--------------------------------->
<div  style="width:480px;margin-left: auto;margin-right: auto;margin-top: 100px;">
    <form class="form-horizontal" method="POST" action="" >
        <h2 style="margin-left:9%;color:#777">Sign up</h2>
        <div class="control-group">
            <label class="control-label" for="inputEmail">Name</label>
            <div class="controls">
                <input type="text" id="inputText" placeholder="Your name" name="name">
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="inputEmail">Email</label>
            <div class="controls">
                <input type="email" id="inputEmail" placeholder="Email" name="email">
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="inputPassword">Password</label>
            <div class="controls">
                <input type="password" id="inputPassword" placeholder="Password" name="password">
            </div>
        </div>
        <div class="control-group">
            <div class="controls">
                <a href="../user/login"><button type="button" class="btn">Back</button></a>
                <button type="submit" class="btn btn-inverse" style="margin-left: 85px">Submit</button>
            </div>
        </div>
    </form>
</div>

<?php
//including footer.php
include '../../include/footer.php';
?>